/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

define([ 'adminapp'], function ($app) {
    $app.navactive('game_rule');
    $.validator.addMethod("consumeIntegral", function() {
        var checked = $("#ruleConsume").attr("checked");
        if (checked) {
            var val = $("#ruleIntegral").val();
            if (val) {
                return true;
            } else {
                return false;
            }
        }
        return true;
    }, "请填写积分");
    $.validator.addMethod("useVirtualCurrency", function() {
        var checked = $("#ruleUseVirtualCurrency").attr("checked");
        if (checked) {
            var val = $("#ruleVirtualCurrency").val();
            if (val) {
                return true;
            } else {
                return false;
            }
        }
        return true;
    }, "请填写虚拟货币");
    $app.formvalidator({
        'rule.winning'       : {
            required : true,
            digits: true
        },
        'rule.total'       : {
            required : true,
            digits: true
        },
        'rule.free_times' : {
            required : true,
            digits: true
        },
        'rule.integral'       : {
            consumeIntegral : true,
            digits: true
        },
        'rule.virtual_currency'       : {
            useVirtualCurrency : true,
            number: true
        },
        'rule.begin_time'       : {
            required : true
        },
        'rule.end_time'       : {
            required : true
        }
    }, 'dataForm');
});